import random
n = input()
print n
for i in range(n):
	for j in range(n):
		if i == j:
			print 0,
		else:
			print random.randint(0, 1),
	print

